#include "temp_api.h"


float MeanMonth(struct sensor info,int n)
{
    return 0;
}

int MinMonth(struct sensor info,int n)
{
    return 0;
}

int MaxMonth(struct sensor info,int n)
{
    return 0;
}

float MeanYear(struct sensor info,int n)
{
    return 0;
}

int MinYear(struct sensor info,int n)
{
    return 0;
}

int MaxYear(struct sensor info,int n)
{
    return 0;
}

int ReadFile(struct sensor info)
{
return 0;
}


void print(struct sensor info, int number)
{
    printf("====================================\n");
    for (int i = 0; i < number; i++)
    {
        printf("%04d-%02d-%02d t=%3d\n",
               info[i].year,
               info[i].month,
               info[i].day,
               info[i].hour,
               info[i].minute,
               info[i].t);
    }
}

void AddRecord(struct sensor info, int number, uint16_t year, uint8_t month, uint8_t day,
               uint8_t hour, uint8_t minute, int8_t t)
{
    info[number].year = year;
    info[number].month = month;
    info[number].day = day;
    info[number].hour = hour;
    info[number].minute = minute;
    info[number].t = t;
}

int DelRecord(struct sensor info, int del, int n)
{
    for (int i = del; i < n; i++)
    {
        info[i] = info[i + 1];
    }
    return n - 1;
}

void changeIJ (struct sensor info, int i, int j) //пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ
{
    struct sensor temp;
    temp   =info[i];
    info[i]=info[j];
    info[j]=temp;
};

void SortByT(struct sensor info, int n)
{
    for (int i=0; i<n; ++i)
    {
        for (int j=i; j<n; ++j)
        {
            if(info[i].t>=info[j].t)
            {
                changeIJ(info,i,j);
            }
        }
    }
}

unsigned int DateToInt(struct sensor info)
{
    return info->year << 40|info->month <<24|info->day <<16|info->hour<<8|info->minute;
};

void SortByDate(struct sensor info, int n)
{
    for (int i=0; i<n; ++i)
    {
        for (int j=i; j<n; ++j)
        {
            if(DateToInt(*info+i)>=DateToInt(*info+j))
            {
                changeIJ(info,i,j);
            }
        }
    }
}